package com.example.rabbitmq.config;

import com.example.rabbitmq.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitMQAckConfig {
    //创建交换机
    @Bean("ackExchange")
    public Exchange ackExchange() {
        return ExchangeBuilder.topicExchange(Constants.ACK_EXCHANGE).durable(true).build();
    }
    //创建交换机
    @Bean("ackQueue")
    public Queue ackQueue() {
        return QueueBuilder.durable(Constants.ACK_QUEUE).build();
    }
    //创建绑定
    @Bean("ackBinding")
    public Binding ackBinding(@Qualifier("ackQueue") Queue queue, @Qualifier("ackExchange") Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("ack").noargs();
    }
}


